package com.atguigu.jxc.controller;


import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    @PostMapping("/list")
    public Map<String,Object> list(Integer page, Integer rows, String supplierName){
        return supplierService.list( page, rows,supplierName);
    }

    @PostMapping("/save")
    public ServiceVO  save(Supplier supplier, @RequestParam(required = false)  Integer supplierId){
        supplier.setSupplierId(supplierId);
        supplierService.save(supplier);
        return new ServiceVO(100,"保存成功");
    }

    @PostMapping("/delete")
    public ServiceVO  delete(String  ids){
        System.out.println(ids);
        supplierService.delete(ids);
        return new ServiceVO(SuccessCode.SUCCESS_CODE,"请求成功");
    }
}
